package day01;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;

public class Test2 {
	public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
		User user = new User();
		user.setAge(10);
		user.setName("dsf");
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("d:/text/a.txt"));
		oos.writeObject(user);
		oos.close();
		
		ObjectInputStream ois = new ObjectInputStream(new FileInputStream("d:/text/a.txt"));
		Object obj = ois.readObject();
		ois.close();		
		User newUser =(User)obj;
		System.out.println(newUser.getAge()+" "+newUser.getName());
	}
}
